<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>

    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">填写顾客反馈</div>
      </div>
      <!--  -->
      <div class="x-pro-list">
        <div class="x-pro-top">基础资料</div>
        <div class="x-pro-pro">
          <div class="x-pro-left">
            <div class="x-pro-row">
              <div class="x-pro-label">门店:</div>
              <div class="x-pro-input">
                {{shop}}
              </div>
            </div>
            <div class="x-pro-row">
              <div class="x-pro-label">记录人:</div>
              <div class="x-pro-input">
                {{thname}}
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--  -->
      <div class="x-pro-list">
        <div class="x-pro-row">
          <div class="x-pro-label">类别:</div>
          <div class="x-pro-input">
            <el-select v-model="thcate" placeholder="请选择" :disabled="isfromindex">
              <el-option v-for="item in catedata" :key="item.id" :label="item.title" :value="item.id"></el-option>
            </el-select>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">方式:</div>
          <div class="x-pro-input">
            <el-select v-model="thtype" placeholder="请选择" :disabled="isfromindex">
              <el-option v-for="item in typedata" :key="item.id" :label="item.title" :value="item.id"></el-option>
            </el-select>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">时间:</div>
          <!-- <div class="x-pro-input">
            <el-time-picker v-model="thtime" placeholder="请选择时间" :value-format="HHmm"></el-time-picker>
          </div> -->
          <div class="x-pro-input" style="display:flex;">
            <el-time-select placeholder="起始时间" v-model="starttime" :picker-options="{start: '04:00',step: '00:30',end: '24:00'}" :editable="notkey" :disabled="isfromindex"></el-time-select>
            <div style="align-self:center;">-</div>
            <el-time-select placeholder="结束时间" v-model="endtime" :picker-options="{start: '04:00',step: '00:30',end: '24:00',minTime: starttime}" :editable="notkey" :disabled="isfromindex"></el-time-select>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">顾客姓名:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="feedname" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">联系方式:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="feedtel" type="number" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">当事人:</div>
          <div class="x-pro-input">
            <el-select v-model="thper" placeholder="请选择" :disabled="isfromindex">
              <el-option v-for="item in perdata" :key="item.id" :label="item.username" :value="item.id"></el-option>
            </el-select>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">处理人:</div>
          <div class="x-pro-input">
            <el-select v-model="thchper" placeholder="请选择" :disabled="isfromindex">
              <el-option v-for="item in perdata" :key="item.id" :label="item.username" :value="item.id"></el-option>
            </el-select>
          </div>
        </div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">经过描述:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="textarea1" type="textarea" :rows="4" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">采取行动:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="textarea2" type="textarea" :rows="4" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">结果呈现:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="textarea3" type="textarea" :rows="4" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">总结经验:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="textarea4" type="textarea" :rows="4" :disabled="isfromindex"></el-input>
          </div>
        </div>
      </div>
      <!--  -->
      <div class="x-pro-gobtn" @click="isok" v-show="!isfromindex">提交</div>
      <!--  -->
      <div class="x-pro-gobtn" @click="isoklike" v-if="islike">推荐</div>
      <div class="x-pro-gobtn x-disabled" v-else>已推荐</div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));
    var thshop = $api.getStorage('storeth')
    var thusername = $api.getStorage('username')
    var tid = api.pageParam.onlyseeid;



    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          thcate:'',
          catedata:'',
          thtype:'',
          typedata:'',
          thtime:'',
          feedname:'',
          feedtel:'',
          thper:'',
          perdata:'',
          thchper:'',
          textarea1:'',
          textarea2:'',
          textarea3:'',
          textarea4:'',
          shop:'',
          thname:'',
          notkey:false,
          starttime:'',
          endtime:'',
          fromonlysee:'',
          isfromindex:false,
          islike:false,

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        that.shop = thshop;
        that.thname = thusername;
        that.fromonlysee = tid;//只读 回显
        console.log(that.fromonlysee);
        if(that.fromonlysee!=undefined){
          that.isfromindex = true;
          that.getshow()
        }
        that.getcate()
        that.gettype()
        that.getperson()

      },
      methods: {
        //回显
        getshow:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/duty/getFeedbackInfo',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:that.fromonlysee
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.thcate = ret.data.cateid;
                that.thtype = ret.data.typeid;
                that.starttime = ret.data.times.slice(0,5);
                that.endtime = ret.data.times.slice(6,11);
                that.feedname = ret.data.username;
                that.feedtel = ret.data.usertel;
                that.thper = ret.data.litigant_memberid;
                that.thchper = ret.data.handle_memberid;
                that.textarea1 = ret.data.desc_str;
                that.textarea2 = ret.data.action_str;
                that.textarea3 = ret.data.result_str;
                that.textarea4 = ret.data.summary_str;
                //
                if(ret.data.like_memberid>0){
                  that.islike = false;
                }else{
                  that.islike = true;
                }


              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //推荐
        isoklike:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/duty/likeFeedback',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:that.fromonlysee,
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.confirm({
                    title: '推荐成功',
                    msg: '',
                    buttons: ['继续编辑', '返回']
                }, function(ret, err) {
                    var index = ret.buttonIndex;
                    that.islike = false;
                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        isok:function(){
          let that=this;
          that.thtime = that.starttime+'-'+that.endtime;
          api.ajax({
            url:baseurl+'api/duty/addFeedback',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                cateid:that.thcate,
                typeid:that.thtype,
                times:that.thtime,
                username:that.feedname,
                usertel:that.feedtel,
                litigant_memberid:that.thper,
                handle_memberid:that.thchper,
                desc_str:that.textarea1,
                action_str:that.textarea2,
                result_str:that.textarea3,
                summary_str:that.textarea4
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.confirm({
                    title: '保存成功',
                    msg: '',
                    buttons: ['继续编辑', '返回']
                }, function(ret, err) {
                    var index = ret.buttonIndex;
                    if(index=='1'){

                    }else{
                      api.sendEvent({
                          name: 'addcustomerfeedok',
                          extra: {

                          }
                      });
                      api.closeWin({});

                    }
                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        getperson:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/person/list',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.perdata = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        getcate:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/duty/getFeedbackCate',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.catedata = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        gettype:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/duty/getFeedbackType',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.typedata = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
